﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Moq;
using SimpleData.ObjectModel.Design;
using SimpleData.Infrastructure.Provider;

namespace SimpleData
{
	public static class RuleBuilderFactoryExtensions
	{
		public static MockBuilder<IProvider<Rule, IRuleBuilder>> RuleBuilderFactory( this IMockInit init )
		{
			return new MockBuilder<IProvider<Rule, IRuleBuilder>>();
		}

		public static MockBuilder<IProvider<Rule, IRuleBuilder>> Create( this MockBuilder<IProvider<Rule, IRuleBuilder>> builder, Func<IRuleBuilder> creator )
		{
			builder
				.Mock
				.Setup( f => f.Create( It.IsAny<Rule>() ) )
				.Returns( creator );

			return builder;
		}

		public static MockBuilder<IProvider<Rule, IRuleBuilder>> Create( this MockBuilder<IProvider<Rule, IRuleBuilder>> builder, Func<Rule, IRuleBuilder> creator )
		{
			builder
				.Mock
				.Setup( f => f.Create( It.IsAny<Rule>() ) )
				.Returns( creator );

			return builder;
		}
	}
}
